<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@page import="org.springframework.data.domain.Page"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>员工绩效查询</title>
<script>
function reset(){
	document.getElementById('datepicker2').value = formatDate(new Date());
	document.getElementById("datepicker2").value = "";
	document.getElementByName("customerName").value = "";
}
function jumpPage(pageNumber){
	document.getElementById('pageNumber').value = pageNumber;
}
</script>
<script>
$(function() {
	$("#datepicker1").datepicker({
		dateFormat : 'yy-mm-dd',
		beforeShow : function(input, inst) {
			inst.dpDiv.css({
				marginTop : -input.offsetHeight + 'px',
				marginLeft : input.offsetWidth + 5 + 'px'
			});
		}
	});
});


$(function() {
	$("#datepicker2").datepicker({
		dateFormat : 'yy-mm-dd',
		beforeShow : function(input, inst) {
			inst.dpDiv.css({
				marginTop : -input.offsetHeight + 'px',
				marginLeft : input.offsetWidth + 5 + 'px'
			});
		}
	});
});

$(document).ready(function() {
	//聚焦第一个输入框
	$("#customerName").focus();
	//为inputForm注册validate函数
	$("#inputForm").validate({
		rules: {
			customerName: "required"
		}
	});
});

$(document).ready(function() {
	$("#message").fadeOut(5000);
	$("#performanceMessage").fadeOut(25000);
});

</script>
</head>

<body>
	<h4 class="prepend-top">员工绩效查询</h4>
	<br>
	<c:if test="${not empty message}">
		<div id="message" class="success">${message}</div>
	</c:if>
	
	<form:form id="inputForm" modelAttribute="search" action="${ctx}/performance/search" method="post">
		<fieldset class="prepend-top">
			<legend>报表查询</legend>
			<div>
				<label for="userName" class="field">安排人员:</label> <select
					style="width: 300px" id="userName" name="userName" size="1">
					<c:forEach var="user" items="${users}">
						<option value="${user.name}"
							<c:if test="${search.userName == user.name }">selected="selected"
						</c:if>>${user.name}</option>
					</c:forEach>
				</select>
			</div>
			<div>
				<label for="status" class="field">是否完成:</label>
				<select  id="status" name="status" style="width: 300px">
						<option value="all"
							<c:if test="${search.status == 'all' }">selected="selected"
						</c:if>>全部显示</option>
						<option value=""
							<c:if test="${search.status == '' }">selected="selected"
						</c:if>>未完成</option>
						<option value="finish"
							<c:if test="${search.status == 'finish' }">selected="selected"
						</c:if>>已完成</option>
				</select>
			</div>
			<input type="text" style="display: none;" id="pageNumber"
				name="pageNumber" size="40" value="${search.pageNumber}" />
			与"预计完成时间"相比较：
			<div>
				<label for="startDate" class="field">起始日期:</label>
				<input type="text" id="datepicker1" name="startDate" size="40" value="<bean:write format="yyyy-MM-dd" name="search" property="startDate"/>"/> 格式:yyyy-MM-dd
			</div>
			<div>
				<label for="endDate" class="field">截止日期:</label>
				<input type="text" id="datepicker2" name="endDate" size="40" value="<bean:write format="yyyy-MM-dd" name="search" property="endDate"/>"/> 格式:yyyy-MM-dd
			</div>
		</fieldset>
		<div>
			<input id="submit" onclick="jumpPage('research')"
				style="margin-left: 450px; text-align: center; width: 120px; height: 30px"
				type="submit" value="查    询" />&nbsp; <input id="reset"
				style="text-align: center; width: 120px; height: 30px" type="reset"
				value="重    置" onclick="reset()" />
		</div>
<c:if test="${pages.totalElements > 0}">
			<h3 class="prepend-top">员工绩效查询结果</h3>
			<c:if test="${not empty performanceMessage}">
				<div id="performanceMessage" class="success">${performanceMessage}</div>
			</c:if>
			<h5 align="right">共${pages.totalElements}条记录|共${pages.totalPages}页|当前${pages.number+1}页|每页${pages.size}条|</h5>
			<div align="right">
			<h4><a  href="exportExcel">导出搜索结果至Excel表格</a></h4>
				<input id="firstone"
					<c:if test="${pages.firstPage}">disabled="disabled"</c:if>
					class="button" type="submit" onclick="jumpPage(0)" value="首页" />&nbsp;
				| <input id="preone"
					<c:if test='<%=!((Page)request.getAttribute("pages")).hasPreviousPage() %>'>disabled="disabled"</c:if>
					class="button" type="submit"
					onclick="jumpPage(${pages.number - 1})" value="上页" />&nbsp; | <input
					id="nextone"
					<c:if test='<%=!((Page)request.getAttribute("pages")).hasNextPage() %>'>disabled="disabled"</c:if>
					class="button" type="submit"
					onclick="jumpPage(${pages.number + 1})" value="下页" />&nbsp; | <input
					id="preone"
					<c:if test='${pages.lastPage}'>disabled="disabled"</c:if>
					class="button" type="submit"
					onclick="jumpPage(${pages.totalPages -1})" value="尾页" />&nbsp;
			</div>
	<table id="contentComPumpTable">
		<tr>
			<th align="center">ID</th>
			<th align="center">客户名称</th>
			<th width="7%" align="center">安排人员</th>
			<th align="center">预计完成时间</th>
			<th align="center">实际完成时间</th>
			<th align="center">是否按时完成</th>
		</tr>
		<c:forEach items="${reports}" var="report" >
			<tr>
				<td><a href="leadto/${report.reportId}">${report.reportId}</a></td>
				<td>${report.customerName}</td>
				<td>${report.assignedUser}</td>
				<td><bean:write format="yyyy-MM-dd" name="report" property="scheduleFinish"/></td>
				<td>
				<c:choose>
				<c:when test="${report.status != 'finish'}">
				未完成
				</c:when>
				<c:otherwise>
				<bean:write format="yyyy-MM-dd" name="report" property="updateTime"/>
				</c:otherwise>
				</c:choose>
				</td>
				
				<td><c:choose>
				<c:when test="${report.end != 'intime'}">
				未按时完成
				</c:when>
				<c:otherwise>
				已按时完成
				</c:otherwise>
				</c:choose></td>
			</tr>
		</c:forEach>
	</table>
	<c:if test="${not empty pages}">
				<div align="right">
					<input id="firstone"
						<c:if test="${pages.firstPage}">disabled="disabled"</c:if>
						class="button" type="submit" onclick="jumpPage(0)" value="首页" />&nbsp;
					| <input id="preone"
						<c:if test='<%=!((Page)request.getAttribute("pages")).hasPreviousPage() %>'>disabled="disabled"</c:if>
						class="button" type="submit"
						onclick="jumpPage(${pages.number - 1})" value="上页" />&nbsp; | <input
						id="nextone"
						<c:if test='<%=!((Page)request.getAttribute("pages")).hasNextPage() %>'>disabled="disabled"</c:if>
						class="button" type="submit"
						onclick="jumpPage(${pages.number + 1})" value="下页" />&nbsp; | <input
						id="preone"
						<c:if test='${pages.lastPage}'>disabled="disabled"</c:if>
						class="button" type="submit"
						onclick="jumpPage(${pages.totalPages -1})" value="尾页" />&nbsp;
				</div>
			</c:if>
		</c:if>
		</form:form>
</body>
</html>
